#ifndef GLOBAL_H
#define GLOBAL_H
#include <QString>
#include <QWidget>
#include "QStyle"
#include <functional>
extern std::function<void(QWidget *)> repolish;

const QStringList default_icons = {":/icon/icon/Durian.png",
                                   ":/icon/icon/lemon.png",
                                   ":/icon/icon/lichee.png",
                                   ":/icon/icon/mango.png",
                                   ":/icon/icon/papaya.png",
                                   ":/icon/icon/carambola.png"
                                   ":/icon/icon/Mangosteen.png",
                                   ":/icon/icon/pineapple.png",
                                   ":/icon/icon/Watermelon.png"};
const QString &GetRandomIcon();

enum ReqId {
    ID_GET_VARIFY_CODE = 1001,        //获取验证码
    ID_REG_USER = 1002,               //注册用户
    ID_RESET_PWD = 1003,              //重置用户密码
    ID_LOGIN_USER = 1004,             //登录
    ID_CHAT_LOGIN = 1005,             //登录聊天服务器
    ID_CHAT_LOGIN_RSP = 1006,         //登录聊天服务器回包
    ID_SEARCH_USER_REQ = 1007,        //用户搜索请求
    ID_SEARCH_USER_RSP = 1008,        //用户搜索回包
    ID_ADD_FRIEND_REQ = 1009,         //添加好友申请
    ID_ADD_FRIEND_RSP = 1010,         //添加好友回包
    ID_NOTIFY_ADD_FRIEND_REQ = 1011,  //通知用户添加好友申请
    ID_AUTH_FRIEND_REQ = 1012,        //认证好友请求
    ID_AUTH_FRIEND_RSP = 1013,        //认证好友回复
    ID_NOTIFY_AUTH_FRIEND_REQ = 1014, //通知用户认证好友申请
    ID_TEXT_CHAT_MSG_REQ = 1015,      //文本聊天消息请求
    ID_TEXT_CHAT_MSG_RSP = 1016,      // 收到文本聊天消息回复
};
enum Modules {
    REGISTERMOD = 0,
    RESETPWDMOD = 1,
    LOGINDMOD = 2,
};
enum TipErr {
    TIP_SUCCESS = 0,
    TIP_EMAIL_ERR = 1,
    TIP_PWD_ERR = 2,
    TIP_CONFIRM_ERR = 3,
    TIP_PWD_CONFIRM = 4,
    TIP_VERIFY_ERR = 5,
    TIP_USER_ERR = 6,
};

enum ErrorCode {
    SUCCESS = 0,
    ERROR_JSON = 1,
    ERROR_NETWORK = 2,
};

enum MessageType { Text = 0, Image = 1 };

struct ServerInfo
{
    QString Host;
    QString Port;
    QString Token;
    int uid;
};
#define IMAGE_MAX_WIDTH 120
#define IMAGE_MAX_HEIGHT 80

struct MsgInfo
{
    QString msgFlag;
    QString content;
    QPixmap pixmap;
};

extern QString gate_url_prefix;

#define MIN_APPLY_LABEL_ED_LEN 40
#define ADD_PREFIX "添加标签:"
#define TIP_OFFSET 5

#define CHAT_COUNT_PER_PAGE 10
#define CONTACT_COUNT_PER_PAGE 10
#endif // GLOBAL_H
